package com.clementheliou.cheliou.business.technical.i18n;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Interface dedicated to the application internationalization (i18n). This is a
 * part of the business layer because other services could use it to generate
 * PDF files for example. This interface is independent of the message's source
 * that should be provided by the web presentation layer(s).
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @since 1.0
 */
public interface I18nTechnicalService {

	/**
	 * Gets this service as a {@link ResourceBundle}. It's useful for web
	 * presentation layers that required a message bundle of this type.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param locale the locale to be used with the resource bundle.
	 * @return an access to this service through a resource bundle.
	 * @see {@link ResourceBundle}.
	 * @since 1.0
	 */
	ResourceBundle getAsResourceBundle(Locale locale);

	/**
	 * Gets the translation of the given key for the given locale. If the
	 * translation is not found, the given key is returned.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param key the given key.
	 * @param locale the locale to be used to translate the key.
	 * @return the translation if it exists, the key otherwise.
	 * @since 1.0
	 */
	String getTranslation(String key, Locale locale);

}
